package patrol.mobile.com.mobilepatrol.activity.security.emergency;

import android.support.v7.widget.RecyclerView;

import com.dl7.recycler.helper.RecyclerViewHelper;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.security.StickyEventJiDi;
import patrol.mobile.com.mobilepatrol.activity.security.adapter.DuiWuAdapter;
import patrol.mobile.com.mobilepatrol.activity.security.adapter.WuZiAdapter;
import patrol.mobile.com.mobilepatrol.bean.Ensure2Bean;
import patrol.mobile.com.mobilepatrol.fragment.BaseFragment;

public class DuiWuFragment extends BaseFragment {


    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    private DuiWuAdapter wuZiAdapter;

    private List<Ensure2Bean.AbkSupportBaseRanksListBean> abkSupportBaseRanksListBeanList = new ArrayList<>();

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_duiwu;
    }


    @Override
    protected void initView() {
        super.initView();
        EventBus.getDefault().register(this);
        wuZiAdapter = new DuiWuAdapter(getContext());
        RecyclerViewHelper.initRecyclerViewV(getContext(), recyclerView, wuZiAdapter);

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void ReceviceMessage(StickyEventJiDi stickyEventJiDi) {
        abkSupportBaseRanksListBeanList = stickyEventJiDi.ensure2BeanList.getAbkSupportBaseRanksList();
        wuZiAdapter.updateItems(abkSupportBaseRanksListBeanList);
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().removeAllStickyEvents();
        EventBus.getDefault().unregister(this);
    }
}
